# generate_skin_paths.gd
@tool
extends EditorScript

func _run():
	var folder_path = "res://skins"
	var output_path = "res://SkinPaths.gd"
	var paths := []

	var dir = DirAccess.open(folder_path)
	if dir:
		dir.list_dir_begin()
		var file_name = dir.get_next()
		while file_name != "":
			if file_name.ends_with(".tres") and not file_name.ends_with(".remap"):
				paths.append(folder_path + "/" + file_name)
			file_name = dir.get_next()
		dir.list_dir_end()
	else:
		push_error("无法打开 " + folder_path)

	# 生成 GDScript 文件
	var file := FileAccess.open(output_path, FileAccess.WRITE)
	if file:
		file.store_line("# 自动生成的皮肤路径文件")
		file.store_line("const SKIN_PATHS = [")
		for path in paths:
			file.store_line('\t"%s",' % path)
		file.store_line("]")
		file.close()
		print("SkinPaths.gd 已生成，路径数量: %d" % paths.size())
	else:
		push_error("无法写入到: " + output_path)
